*******************************************************************************
* Load voter data
*******************************************************************************

use dataset_voters, clear

*******************************************************************************
* Specify variables we want to summarize
*******************************************************************************

local myvars white_self female_self age_self educ_self ///
	marijuana_self deathpenalty_self threestrikes_self

*******************************************************************************
* Collapse to respondent level
*******************************************************************************

collapse `myvars', by(responseid sample)

*******************************************************************************
* Collapse to variable-sample level
*******************************************************************************

bys sample: su `myvars'

collapse `myvars', by(sample)

*******************************************************************************
* Transpose and format
*******************************************************************************

xpose, clear var
rename v2 Mturk
rename v1 Forthright
drop if _n == 1
order _varname Mturk Forthright
tostring Mturk Forthright, replace force format("%20.02fc")
list

replace _v = subinstr(_v, "_self", "", 1)
replace _v = proper(_v)
replace _v = "BA or above" if _v == "Educ"
replace _v = "Oppose death penalty" if _v == "Deathpenalty"
replace _v = "Oppose three strikes" if _v == "Threestrikes"
replace _v = "Support legal marijuana" if _v == "Marijuana"
replace Forth = "(N/A)" if Forth == "."

*******************************************************************************
* Output
*******************************************************************************

#delimit;

listtex 
	using "_output/tableS11.tex"
	,
	replace
	type rstyle(tabular)
	head(
		\begin{tabular*}
		{0.8\hsize}{@{\hskip\tabcolsep\extracolsep\fill}l*{3}{l}}
		\toprule 
		 & Mturk Sample & Forthright Sample
		\\
		\midrule
	)
	foot("\bottomrule\end{tabular*}")
	;
	
#delimit cr

*******************************************************************************
* End
*******************************************************************************
